<?php

use think\migration\Seeder;
use app\common\model\Options as OptionsModel;

class InitDefaultOptions extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {

        $lists = [
            'site_options' => [
                'site_name' => 'TPCMS',
                'site_host' => 'http://localhost',
                'site_icp' => '京ICP备15049788号-7',
                'site_tongji' => '',
                'site_copyright' => 'Power By <a href="">Laifuzi</a>',
                'site_co_name' => '',
                'site_address' => '',
                'site_tel' => '18302902891',
                'site_admin_email' => 'zhanghong_bean@126.com',
                'site_qq' => '305839090',
                'site_seo_title' => 'TPCMS',
                'site_seo_keywords' => 'CMS,ThinkPHP,建站',
                'site_seo_description' => 'a cms write with ThinkPHP',
            ], 'url_options' => [
                'url_model' => 3,
                'url_suffix' => 'html',
            ], 'active_options' => [
                'email_active' => false,
                'email_title' => '',
                'email_tpl' => ''
            ], 'oauth_options' => [
                'qq_appid' => '',
                'qq_appkey' => '',
                'sina_appid' => '',
                'sina_appkey' => '',
            ],
        ];

        $OptionsModel = new OptionsModel();
        foreach ($lists as $name => $options) {
            if($OptionsModel->where('name', $name)->count()){
                continue;
            }
            $OptionsModel->saveSetting($name, $options);
        }
    }
}